"""
文件 状态
"""
from dataclasses import dataclass
from typing import List

import reflex as rx
from devtools import debug

from base.state import StateBase


# @dataclass
# class AlertStateMixin:
#     opened: bool = False
#
#     def open(self):
#         self.opened = True
#
#     def close(self):
#         self.opened = False


class FileUploadState(StateBase):
    """ 文件上传状态 """

    file_name: str = "No Name"

    def file_upload(self, files: List[rx.UploadFile]):
        for file in files:
            debug(file.filename)
            debug(file.size)
            debug(file.content_type)

            debug(file.__dict__)

            self.file_name = file.filename
